// =================================================================================================
//
//	CopyEngine Framework
//	Copyright 2012 Eran. All Rights Reserved.
//
//	This program is free software. You can redistribute and/or modify it
//	in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================

/**
 * Created by eran on 15-1-18.
 */
package gui.component.mapEditor.block.ext
{
    import data.BlockVo;

    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;

    public class MonsterBlockTileExtInfoRender extends BlockTileExtInfoRenderBasic
    {
        private var mExtInfoTextField:TextField;

        public function MonsterBlockTileExtInfoRender()
        {
            super();
        }

        override protected function doInitialize():void
        {
        }


        override public function show(_vo:BlockVo):void
        {
            mExtInfoTextField = new TextField();
            mExtInfoTextField.autoSize = TextFieldAutoSize.LEFT;
            mExtInfoTextField.wordWrap = true;
            mExtInfoTextField.multiline = true;

            mExtInfoTextField.text = "ATK:" + _vo.attackNum + "\n";
            mExtInfoTextField.text += "DEF:" + _vo.defendNum + "\n";
            mExtInfoTextField.text += "B: " + _vo.maxBloodNum + "\n";
            mExtInfoTextField.text += "Exp: " + _vo.expNum;
            mExtInfoTextField.width = mExtInfoTextField.textWidth + 25;
            mExtInfoTextField.height = mExtInfoTextField.textHeight + 10;
            mExtInfoTextField.textColor = 0xFFFFFF;

            var minScale:Number = mRenderContainer.width / mExtInfoTextField.width;
            minScale = Math.min(minScale, mRenderContainer.height / mExtInfoTextField.height);
            mExtInfoTextField.scaleX = mExtInfoTextField.scaleY = minScale;


            mExtInfoTextField.x = (mRenderContainer.width - mExtInfoTextField.width) / 2;
            mExtInfoTextField.y = (mRenderContainer.height - mExtInfoTextField.height) / 2;
            mRenderContainer.addChild(mExtInfoTextField);
        }

        override public function hide():void
        {
            if (mExtInfoTextField != null && mExtInfoTextField.parent != null)
            {
                mExtInfoTextField.parent.removeChild(mExtInfoTextField);
            }
            mExtInfoTextField = null;
        }

        override public function isCanRenderExtInfo(_voType:int):Boolean
        {
            return _voType == MapEditorConfig.getBlockTypeByInfoKey("Monster") ||
                   _voType == MapEditorConfig.getBlockTypeByInfoKey("LevelBoss");
        }
    }
}
